/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlrpc.client;

import java.net.MalformedURLException;
import java.net.URL;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.util.ClientFactory;

/**
 *
 * @author martin
 */
public class Calculate_remote {
  public static void main (String [] args) throws XmlRpcException, MalformedURLException {
      XmlRpcClient xmlrpc = new XmlRpcClient();
      XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
      config.setServerURL(new URL("http://localhost:8088"));
      xmlrpc.setConfig(config);

      String result = (String) xmlrpc.execute ("sample.add", new Object[]{2,4}).toString();
      //System.out.println(result);
      
      ClientFactory cf = new ClientFactory(xmlrpc);
      Calculate_interface tmp = (Calculate_interface) cf.newInstance(Calculate_interface.class.getClassLoader(),Calculate_interface.class,"sample");
      System.out.println("5+8="+tmp.add(5, 8));
   }
}
